import { FormSchema } from "/@/components/Form";
import { DescItem } from "/@/components/Description";
import { RoleEnum } from "/@/enums/roleEnum";
import { GroupTypeEnum } from "/@/enums/typeEnum";
import { usePermission } from "/@/hooks/web/usePermission";

const { hasPermission } = usePermission();

export const descSchema: DescItem[] = [
  {
    field: "groupName",
    label: "小组名称",
    contentMinWidth: 300,
  },
  {
    field: "type",
    label: "小组类型",
    render: (value) => {
      switch (value) {
        case GroupTypeEnum.DEFAULT:
          return "普通小组";
        case GroupTypeEnum.PRACTICAL:
          return "实习小组";
        default:
          return "非法类型";
      }
    },
  },
  {
    field: "total",
    label: "小组人数",
  },
  {
    field: "stock",
    label: "可选人数",
  },
  {
    field: "introduction",
    label: "小组介绍",
  },
];

export const formSchema: FormSchema[] = [
  {
    field: "groupId",
    label: "小组主键",
    component: "InputNumber",
    show: false,
  },
  {
    field: "groupName",
    label: "小组名称",
    component: "Input",
    required: true,
  },
  {
    field: "type",
    label: "小组类型",
    component: "Select",
    required: true,
    ifShow: hasPermission(RoleEnum.ROLE_INSTRUCTOR),
    componentProps: {
      options: [
        {
          label: "普通小组",
          value: GroupTypeEnum.DEFAULT,
        },
        {
          label: "实践小组",
          value: GroupTypeEnum.PRACTICAL,
        },
      ],
    },
  },
  {
    field: "total",
    label: "小组人数",
    component: "InputNumber",
    required: true,
  },
  {
    field: "introduction",
    label: "小组介绍",
    component: "InputTextArea",
    componentProps: {
      rows: 4,
    },
  },
];
